package org.nokatag.tagjava;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;

import org.nokatag.system.BugInfoWrint;

/**
 * 删除表单按钮
 * @author rebin
 * 
 */
public class DeleteButton extends Inputsuper{
	private static final long serialVersionUID = 2059077049501772497L;
	private String val = null;//设置成变量
	private String shortcutkey=null;//快捷键  altKey|shiftKey|ctrlKey+ctrlKey+13
	
	public int doStartTag()throws JspException{
		JspWriter jspOut = pageContext.getOut();
		HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
		String sformid = "";
		boolean isShow = true;//是否显示
		FormHtml fh = getTagFormHtml(this);
		if(null!=fh){
			sformid = fh.getId();
		}
		//---------------生成按钮--------------------------------------
		if(isShow){
			FormHtmlInsertid(getId(),getName(),getValue());
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.append(potjs(request));
			stringBuilder.append(nkUtiljs(request));
			stringBuilder.append("<input type=\"button\" ");
			stringBuilder.append(getBaseStr()+"/>");
			stringBuilder.append("<script type=\"text/javascript\">");
			stringBuilder.append("Event.observe(document, 'dom:loaded', function() {");// altKey shiftKey
			stringBuilder.append("var cfgs"+getId()+" = {id:'"+getId()+"',formid:'"+sformid+"'};");
			stringBuilder.append("var ndelp"+getId()+" = new NKFormDelButton(cfgs"+getId()+");");
			stringBuilder.append("ndelp"+getId()+".show();");
			stringBuilder.append("});");
			stringBuilder.append("</script>");
			stringBuilder.append(shortcutkey(shortcutkey,getId(),null));
			try {
				if(val!=null)
					request.setAttribute(val, stringBuilder.toString());
				else
					jspOut.write(stringBuilder.toString());
			} catch (IOException e) {
				BugInfoWrint.Print(e);
			}
		}
		return EVAL_BODY_INCLUDE;
	}

	

	public String getVal() {
		return val;
	}

	public void setVal(String val) {
		this.val = val;
	}


	public String getShortcutkey() {
		return shortcutkey;
	}

	public void setShortcutkey(String shortcutkey) {
		this.shortcutkey = shortcutkey;
	}
}
